package com.spark.gaea.config.service.easyzk;

import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import org.apache.curator.RetryPolicy;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class ConfigProfile {
	private final String connectStr;
	private final String rootNode;
	private final String version;
	private final RetryPolicy retryPolicy;

	public ConfigProfile(final String connectStr, final String rootNode) {
		this(connectStr, rootNode, "1.0.0", new ExponentialBackoffRetry(100, 2));
	}

	public ConfigProfile(final String connectStr, final String rootNode, final String versionString,
			final RetryPolicy retryPolicy) {
		this.connectStr = Preconditions.checkNotNull(connectStr);
		this.rootNode = Preconditions.checkNotNull(rootNode);
		this.version = Preconditions.checkNotNull(versionString);
		this.retryPolicy = Preconditions.checkNotNull(retryPolicy);
	}

	public String getConnectStr() {
		return this.connectStr;
	}

	public String getRootNode() {
		return this.rootNode;
	}

	public String getVersion() {
		return this.version;
	}

	public RetryPolicy getRetryPolicy() {
		return this.retryPolicy;
	}

	@Override
	public String toString() {
		return MoreObjects.toStringHelper(this).add("connectStr", this.connectStr).add("rootNode", this.rootNode)
				.add("retryPolicy", this.retryPolicy).toString();
	}
}
